<?php
 ini_set('display_errors', 0);
my_component_load('testing' , false);
my_component_load('paging' , false);   
my_component_load('data_setting', false);
my_component_load('list_kalender' , false); 
//my_component_load('pr_rapel' ,false); 
my_component_load('pr_kenaikan_gaji' );
$task = isset($_GET['task']) ? $_GET['task'] : "";  
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$karyawan_id= isset( $_GET['karyawan_id'] ) ? $_GET['karyawan_id']:  0;
$tanggal = isset($_GET['tanggal']) ? $_GET['tanggal'] : "";  
$value = isset($_GET['value']) ? $_GET['value'] : "";  

$modulname = "Penggajian _BN_ Kenaikan Gaji";

if($_SERVER['REQUEST_METHOD'] == "POST" ){
	if($task=='kenaikan_page'){
		$validatepost = kenaikan_validate($id);
		if($validatepost){
			$errors = message_multi_error($validatepost);
			$content = $errors;
			$content .= form_kenaikan_create($id);
			generate_my_web($content,"","plain.php");
			exit; 
		}else {
			form_kenaikan_submit($id); 
			$content =  "Updated";
			generate_my_web($content,"","plain.php");
			exit;
		}
		break; 	
	}elseif($task == 'exception_page_form'){
		submit_pengecualian($id);
		my_direct('index.php?com=pr_kenaikan_gaji&id='.$id.'&task=exception_page');
	}
	my_direct('index.php?com=pr_kenaikan_gaji');
	break;	
}else{ 
	if($task == "kenaikan_create"){
		facebox_page( 'index.php?com='.$_GET['com'].'&task=kenaikan_page&id='.$id,  ' ', 220	);
	}elseif($task == "kenaikan_page"){
		$pagename = $modulname." _BN_ Detail _BN_ Setting Jadwal Kerja";
		$view =  form_kenaikan_create($id);
		generate_my_web($view,"","plain.php");
		exit;				
	}elseif($task =="list_detail"){
		load_facebox_script();
		$pagename = $modulname." _BN_ Detail";
		$view =  list_kenaikan_detail($id);
	}elseif($task == 'delete'){ 
		delete_kenaikan($id);
		my_direct('index.php?com=pr_kenaikan_gaji');

	}elseif($task =='loadpage'){
		$title="Proses Kenaikan Gaji";
		facebox_page('index.php?com='.$_GET['com'].'&id='.$id.'&task=vpage&p='.rand(0,999999) , $title , 120	); 
	}elseif($task =='vpage'){
		$content = page_kalkulasi_kenaikan($id); 
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == 'exception'){ 
		$title="Proses Kenaikan Gaji Data Pengeculian";
		facebox_page('index.php?com='.$_GET['com'].'&id='.$id.'&task=exception_page&p='.rand(0,999999) , $title , 220	);
	}elseif($task == 'exception_page_delete'){ 
		delete_exception($id , $karyawan_id);
		my_direct($_SERVER['HTTP_REFERER']);
	}elseif($task == 'exception_page'){ 
		$content = exception_grid_data($id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == 'exception_page_form'){
		$content = form_pengecualian_kenaikan(0);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == 'proses'){ 
		update_kenaikan_karyawan($id) ;
		echo button_icon( 'check2.png' ,'')."<br/>Done !!";
		exit;
	}elseif($task =="list_karyawan"){
		load_facebox_script();
		$pagename = $modulname." _BN_ Detail";
		$view =  list_karyawan($id,$karyawan_id);		
	}elseif($task == "plaincetak"){
		@ob_end_clean(); 
		echo'<pre>';
		echo print_plain($id);
		exit;
	}elseif($task == "excel"){
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=kenaikan_gaji".rand().".xls");
		echo excel_report($id);
		exit;		
	}else{
		$pagename = $modulname;
		load_facebox_script();
		$view =  list_kenaikan();
	}
	generate_my_web($view , $pagename );	
}


